defmodule Iocp.Application do
  # See https://hexdocs.pm/elixir/Application.html
  # for more information on OTP Applications
  @moduledoc false

  use Application

  def start(_type, _args) do
    port = Application.get_env(:iocp, :port, 4500)
    dump_path = Application.get_env(:iocp, :dump_path, "/tmp/iocp.dump")
    # List all child processes to be supervised
    children = [
      # Starts a worker by calling: Iocp.Worker.start_link(arg)
      # {Iocp.Worker, arg},
      {Iocp.Server.Supervisor, port},
      {Iocp.Worker.Supervisor, []},
      {Task.Supervisor, name: Iocp.Task.Supervisor},
      {Iocp.Dumper, dump_path}
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: Iocp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end
